package com.etime.dao.impl;

import com.etime.dao.ShowDao;
import com.etime.entity.Student;
import com.etime.util.C3P0Util;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.util.List;

public class ShowDaoImpl implements ShowDao {
  @Override
  public List<Student> show() {
    Student student = new Student();
    List<Student> list = null;
    QueryRunner queryRunner = new QueryRunner(C3P0Util.getDataSource());
    String sql = "select * from student";
    BeanListHandler<Student> beanListHandler = new BeanListHandler<>(Student.class);
    try {
      list = queryRunner.query(sql, beanListHandler);
    }
    catch (Exception e){
      System.out.println(e);
    }
    return list;
  }
}
